﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<!-- 下拉框 -->
<link rel="stylesheet" href="static/ace/css/chosen.css" />
<!-- jsp文件头和头部 -->
<%@ include file="../../system/index/top.jsp"%>
<!-- 日期框 -->
<link rel="stylesheet" href="static/ace/css/datepicker.css" />
</head>
<body class="no-skin">

	<!-- /section:basics/navbar.layout -->
	<div class="main-container" id="main-container">
		<!-- /section:basics/sidebar -->
		<div class="main-content">
			<div class="main-content-inner">
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<!-- 检索  -->
							<form action="fruitUser/listFruitUsers" method="post"
								name="userForm" id="userForm">
								<table style="margin-top: 5px;">
									<tr>
										<td>
											<div class="nav-search">
												<span class="input-icon"> <input
													class="nav-search-input" autocomplete="off"
													id="nav-search-input" type="text" name="keywords"
													value="${pd.keywords }" placeholder="这里输入昵称关键词" /> <i
													class="ace-icon fa fa-search nav-search-icon"></i>
												</span>
											</div>
										</td>
										<td>
											<div class="nav-search">
												<span class="input-icon"> <input
													class="nav-search-input" autocomplete="off"
													id="nav-search-input" type="text" name=keywordsUID
													value="${pd.keywordsUID }" placeholder="这里输入UID关键词" /> <i
													class="ace-icon fa fa-search nav-search-icon"></i>
												</span>
											</div>
										</td>
										<td>
											<div class="nav-search">
												<span class="input-icon"> <input
													class="nav-search-input" autocomplete="off"
													id="nav-search-input" type="text" name="keywordsPHONE"
													value="${pd.keywordsPHONE }" placeholder="这里输入手机号关键词" /> <i
													class="ace-icon fa fa-search nav-search-icon"></i>
												</span>
											</div>
										</td>

										<c:if test="${QX.cha == 1 }">
											<td style="vertical-align: top; padding-left: 2px;"><a
												class="btn btn-light btn-xs" onclick="searchs();" title="检索"><i
													id="nav-search-icon"
													class="ace-icon fa fa-search bigger-110 nav-search-icon blue"></i></a></td>
										</c:if>
									</tr>
								</table>

								<!-- 检索  -->
								<table id="simple-table"
									class="table table-striped table-bordered table-hover"
									style="margin-top: 5px;">
									<thead>
										<tr>
											<th class="center" style="width: 35px;"><label
												class="pos-rel"><input type="checkbox" class="ace"
													id="zcheckbox" /><span class="lbl"></span></label></th>
											<th class="center" style="width: 50px;">UID</th>
											<th class="center">昵称</th>
											<th class="center">手机号</th>
											<th class="center">余额</th>
											<th class="center">积分</th>
											<th class="center">状态</th>
											<th class="center"><i
												class="ace-icon fa fa-clock-o bigger-110 hidden-480"></i>注册日期</th>

											<th class="center">操作</th>
										</tr>
									</thead>
									<tbody>

										<!-- 开始循环 -->
										<c:choose>
											<c:when test="${not empty fruitUserList}">
												<c:if test="${QX.cha == 1 }">
													<c:forEach items="${fruitUserList}" var="user" varStatus="vs">
														<tr>
															<td class='center' style="width: 30px;"><label><input
																	type='checkbox' name='ids' value="${user.userId }"
																	id="${user.email }" alt="${user.phone }" class="ace" /><span
																	class="lbl"></span></label></td>
															<td class='center' style="width: 30px;">${user.userId}</td>
															<td class="center">${user.petName }</td>
															<td class="center">${user.phone }</td>
															<td class="center">${user.balance }</td>
															<td class="center">${user.points }</td>
															<td style="width: 60px;" class="center">
															    <c:if test="${user.state == '01' }">
																	<span class="label label-success arrowed">正常</span>
																</c:if> 
																<c:if test="${user.state == '02' }">
																	<span class="label label-important arrowed-in">停用</span>
																</c:if>
															</td>
															<td class="center">${user.creationDate}</td>

															<td class="center"><c:if
																	test="${QX.edit != 1 && QX.del != 1 }">
																	<span
																		class="label label-large label-grey arrowed-in-right arrowed-in"><i
																		class="ace-icon fa fa-lock" title="无权限"></i></span>
																</c:if>
																<div class="hidden-sm hidden-xs btn-group">
																
																	<%-- <c:if test="${user.LEVEL != 0 }"> --%>
																	
																		
																	<%-- <c:if test="${QX.edit == 1 }">
																		<a class="btn btn-xs btn-info" title="个人详情"
																			onclick="editUser('${user.userId}');"> <i
																			class="ace-icon fa fa-users bigger-120"
																			title="个人详情"></i>
																		</a>
																	</c:if> --%>

																	<c:if test="${QX.add == 1 }">
																		<a class="btn btn-xs btn-success" title="企业认证"
																			onclick="editUserCompany('${user.userId}');"> <i
																			class="ace-icon fa fa-calendar bigger-120"
																			title="企业认证"></i>
																		</a>
																	</c:if>
																	
																	<c:if test="${QX.edit == 1 }">
																		<c:if test="${user.state =='1' }">
																			<a class="btn btn-xs" title="停用"
																				onclick="editUserSTATE('${user.userId}','${user.state}');"> <i
																				class="ace-icon fa fa-lock bigger-120"
																				title="停用"></i>
																			</a>
																		</c:if>
																		<c:if test="${user.state =='02' }">
																			<a class="btn btn-xs btn-success" title="启用"
																				onclick="editUserSTATE('${user.userId}','${user.state}');"> <i
																				class="ace-icon fa fa-unlock bigger-120"
																				title="启用"></i>
																			</a>
																		</c:if>
																	</c:if>
																	<%-- <c:if test="${QX.edit == 1 }">
																		<a class="btn btn-xs btn-info" title="编辑"
																			onclick="editUserinfo('${user.userId}');"> <i
																			class="ace-icon fa fa-pencil-square-o bigger-120"
																			title="编辑"></i>
																		</a>
																	</c:if> --%>
																	<c:if test="${QX.del == 1 }">
																		<a class="btn btn-xs btn-danger"
																			onclick="delUser('${user.userId }','${user.petName }');">
																			<i class="ace-icon fa fa-trash-o bigger-120"
																			title="删除"></i>
																		</a>
																	</c:if>
																	
																	
																</div>
																<div class="hidden-md hidden-lg">
																	<div class="inline pos-rel">
																		<button
																			class="btn btn-minier btn-primary dropdown-toggle"
																			data-toggle="dropdown" data-position="auto">
																			<i class="ace-icon fa fa-cog icon-only bigger-110"></i>
																		</button>
																		<ul
																			class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
																		
																		
																		</ul>
																	</div>
																</div></td>
														</tr>
													</c:forEach>
												</c:if>
												<c:if test="${QX.cha == 0 }">
													<tr>
														<td colspan="100" class="center">您无权查看</td>
													</tr>
												</c:if>
											</c:when>
											<c:otherwise>
												<tr class="main_info">
													<td colspan="100" class="center">没有相关数据</td>
												</tr>
											</c:otherwise>
										</c:choose>
									</tbody>
								</table>
								<div class="page-header position-relative">
									<table style="width: 100%;">
										<tr>
										   <td style="vertical-align:top;">
									           <c:if test="${QX.add == 1 }">
									              <a class="btn btn-mini btn-success" onclick="add();">新增</a>
									              </c:if>
								                 </td>
											<td style="vertical-align: top;">
												<c:if test="${QX.del == 1 }">
													<a title="批量删除" class="btn btn-mini btn-danger"
														onclick="makeAll('确定要删除选中的数据吗?');"><i
														class='ace-icon fa fa-trash-o bigger-120'></i></a>
												</c:if></td>
											<td style="vertical-align: top;"><div class="pagination"
													style="float: right; padding-top: 0px; margin-top: 0px;">${page.pageStr}</div></td>
										</tr>
									</table>
								</div>
							</form>
						</div>
						<!-- /.col -->
					</div>
					<!-- /.row -->
				</div>
				<!-- /.page-content -->
			</div>
		</div>
		<!-- /.main-content -->
		<!-- 返回顶部 -->
		<a href="#" id="btn-scroll-up"
			class="btn-scroll-up btn btn-sm btn-inverse"> <i
			class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
		</a>
	</div>
	<!-- /.main-container -->
	<!-- basic scripts -->
	<!-- 页面底部js¨ -->
	<%@ include file="../../system/index/foot.jsp"%>
	<!-- 删除时确认窗口 -->
	<script src="static/ace/js/bootbox.js"></script>
	<!-- ace scripts -->
	<script src="static/ace/js/ace/ace.js"></script>
	<!-- 日期框 -->
	<script src="static/ace/js/date-time/bootstrap-datepicker.js"></script>
	<!-- 下拉框 -->
	<script src="static/ace/js/chosen.jquery.js"></script>
	<!--提示框-->
	<script type="text/javascript" src="static/js/jquery.tips.js"></script>
</body>
<script type="text/javascript">
		$(top.hangge());
		
		$(function() {
			//日期框
			$('.date-picker').datepicker({autoclose: true,todayHighlight: true});
			
			//下拉框
			if(!ace.vars['touch']) {
				$('.chosen-select').chosen({allow_single_deselect:true}); 
				$(window)
				.off('resize.chosen')
				.on('resize.chosen', function() {
					$('.chosen-select').each(function() {
						 var $this = $(this);
						 $this.next().css({'width': $this.parent().width()});
					});
				}).trigger('resize.chosen');
				$(document).on('settings.ace.chosen', function(e, event_name, event_val) {
					if(event_name != 'sidebar_collapsed') return;
					$('.chosen-select').each(function() {
						 var $this = $(this);
						 $this.next().css({'width': $this.parent().width()});
					});
				});
				$('#chosen-multiple-style .btn').on('click', function(e){
					var target = $(this).find('input[type=radio]');
					var which = parseInt(target.val());
					if(which == 2) $('#form-field-select-4').addClass('tag-input-style');
					 else $('#form-field-select-4').removeClass('tag-input-style');
				});
			}
			
			//复选框全选控制
			var active_class = 'active';
			$('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function(){
				var th_checked = this.checked;//checkbox inside "TH" table header
				$(this).closest('table').find('tbody > tr').each(function(){
					var row = this;
					if(th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
					else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
				});
			});
		});
		
		//检索
		function searchs(){
			top.jzts();
			$("#userForm").submit();
		}
	
		//新增
		function add(){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="新增";
			 diag.URL = '<%=basePath%>fruitUser/goAddUser';
			 diag.Width = 500;
			 diag.Height = 300;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location=self.location",100);
					 }else{
						 nextPage('${page.currentPage}');
					 }
				}
				diag.close();
			 };
			 diag.show();
		}

		
		//上级好友
		function editvipuserTop(id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="上级好友";
			 diag.URL = '<%=basePath%>vipUserInfo/gouserTop.do?ID='+id;
			 diag.Width = 660;
			 diag.Height = 470;
			 diag.CancelEvent = function(){ //关闭事件
				diag.close();
			 };
			 diag.show();
		}
		
		
		//下級好友
		function editRights(id){
			debugger;
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag = true;
			 diag.Title = "下级好友列表";
			 diag.URL = '<%=basePath%>vipUserInfo/user_menuqx.do?id='+id;
			 diag.Width = 660;
			 diag.Height = 450;
			 diag.CancelEvent = function(){ //关闭事件
				diag.close();
			 };
			 diag.show();
		}
		
		//VIP会员奖金比例
		function editVIPRights(id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag = true;
			 diag.Title = "VIP会员奖金比率";
			 diag.URL = '<%=basePath%>vipUserInfo/listvipuserinfo?id='+id;
			 diag.Width = 660;
			 diag.Height = 450;
			 diag.CancelEvent = function(){ //关闭事件
				diag.close();
			 };
			 diag.show();
		}
		
		//个人详情
		function editUser(id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="个人详情";
			 diag.URL = '<%=basePath%>userinfo/goEditU.do?ID='+id;
			 diag.Width = 600;
			 diag.Height = 319;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage('${page.currentPage}');
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//去 修改数值 页面
		function editUserCompany(userId){
			
			window.location.href="<%=basePath%>real/toCompany.do?"+userId;

		}
		//去 升级vip
		function toEditUserVIP(id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="VIP升级";
			 diag.URL = '<%=basePath%>userinfo/toEditUserVIP.do?ID='+id;
			 diag.Width = 600;
			 diag.Height = 419;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage('${page.currentPage}');
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//停用  启用   
		function editUserSTATE(id,state){
				var states="";
				if(state=="1"){
					states="停用";
				}else if(state=="2"){
					
					states="启用";
				}
				bootbox.confirm("确定"+states+"吗?", function(result) {
					if(result) {
						top.jzts();
						var url = '<%=basePath%>userinfo/editUserSTATE.do?ID='+id;
						$.get(url,function(data){
							if(data=="success"){
								alert(states+"成功！");	
							}else{
								alert(states+"失败！");
							}
							nextPage('${page.currentPage}');
						});
					};
				});
		}
		
		// 去编辑
		function editUserinfo(id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="会员资料";
			 diag.URL = '<%=basePath%>userinfo/goEditUserinfo.do?ID='+id;
			 diag.Width = 600;
			 diag.Height = 419;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage('${page.currentPage}');
				}
				diag.close();
			 };
			 diag.show();
		}
	
		//删除
		function delUser(id,msg){
			bootbox.confirm("确定要删除["+msg+"]吗?", function(result) {
				if(result) {
					top.jzts();
					var url = "<%=basePath%>fruitUser/deleteU?ID="+id+"&tm="+new Date().getTime();
					$.get(url,function(data){
						nextPage('${page.currentPage}');
					});
				}
			});
		}
		
		//批量操作
		function makeAll(msg){
			bootbox.confirm(msg, function(result) {
				if(result) {
					var str = '';
					var emstr = '';
					var phones = '';
					for(var i=0;i < document.getElementsByName('ids').length;i++)
					{
						  if(document.getElementsByName('ids')[i].checked){
						  	if(str=='') str += document.getElementsByName('ids')[i].value;
						  	else str += ',' + document.getElementsByName('ids')[i].value;
						  	
						  	if(emstr=='') emstr += document.getElementsByName('ids')[i].id;
						  	else emstr += ';' + document.getElementsByName('ids')[i].id;
						  	
						  	if(phones=='') phones += document.getElementsByName('ids')[i].alt;
						  	else phones += ';' + document.getElementsByName('ids')[i].alt;
						  }
					}
					if(str==''){
						bootbox.dialog({
							message: "<span class='bigger-110'>您没有选择任何内容!</span>",
							buttons: 			
							{ "button":{ "label":"确定", "className":"btn-sm btn-success"}}
						});
						$("#zcheckbox").tips({
							side:3,
				            msg:'点这里全选',
				            bg:'#AE81FF',
				            time:8
				        });
						
						return;
					}else{
						if(msg == '确定要删除选中的数据吗?'){
							top.jzts();
							$.ajax({
								type: "POST",
								url: '<%=basePath%>fruitUser/deleteAllU.do?tm='+new Date().getTime(),
						    	data: {USER_IDS:str},
								dataType:'json',
								//beforeSend: validateData,
								cache: false,
								success: function(data){
									 $.each(data.list, function(i, list){
											nextPage('${page.currentPage}');
									 });
								}
							});
						}else if(msg == '确定要给选中的用户发送邮件吗?'){
							sendEmail(emstr);
						}else if(msg == '确定要给选中的用户发送短信吗?'){
							sendSms(phones);
						}
						
					}
				}
			});
		}
		
		</script>
</html>
